let minprice=null;
let maxprice=null;
let str=null;
let minArea=null;
let maxArea=null;
let address=null;
let sumHouse=null;
let code=null;

//房间
	$('.sumHouse a').click(function() {
		sumHouse = $('.sumHouse a').eq($(this).index()).text();
		if (sumHouse == "一室") {
			sumHouse = 1;
		} else if (sumHouse == "两室") {
			sumHouse = 2;
		} else if (sumHouse == "三室") {
			sumHouse = 3;
		} else if (sumHouse == "四室") {
			sumHouse = 4;
		} else {
			sumHouse = null;
		}
        eventHand();
	});
	//面积
	$('.myarea a').click(function() {
		str = $('.myarea a').eq($(this).index()).text();
		if (str == "20-40平方") {
			minArea = 20;
			maxArea = 40;
		} else if (str == "41-60平方") {
			minArea = 41;
			maxArea = 60;
		} else if (str == "61-80平方") {
			minArea = 61;
			maxArea = 80;
		} else if (str == "100平方以上") {
			minArea = 100;
			maxArea = null;
		} else if (str == "20平方以下") {
			maxArea = 20;
			minArea = null;
		} else {
			minArea = null;
			maxArea = null;
		}
        eventHand();
	});
	//地址
	$('.address a').click(function() {
		str = $('.address a').eq($(this).index()).text();
		if (str == ("不限")) address = null;
		else {
			address = str;
		}
        eventHand();
	});
	//价格
	$("#price0").click(function() {
		maxprice = null;
		minprice=null;
        eventHand();
	})
	$("#price1").click(function() {
		maxprice = 500;
		minprice=null;
        eventHand();
	})
	$("#price2").click(function() {
		let str = document.getElementById("price2").outerText;
		minprice = str.split("-")[0];
		maxprice = str.split("-")[1];
        eventHand();
	})
	$("#price3").click(function() {
		let str = document.getElementById("price3").outerText;
		minprice = str.split("-")[0];
		maxprice = str.split("-")[1];
        eventHand();
	})
	$("#price4").click(function() {
		let str = document.getElementById("price4").outerText;
		minprice = str.split("-")[0];
		maxprice = str.split("-")[1];
        eventHand();
	})
	$("#price5").click(function() {
		let str = document.getElementById("price5").outerText;
		minprice = str.split("-")[0];
		maxprice = str.split("-")[1];
        eventHand();
	})
	$("#price6").click(function() {
		minprice = 4000;
		maxprice=null;
        eventHand();
	})
    //返回json
function getData() {

	  return new Promise((resolve, reject) => {
          $.ajax({
              type: "get",
              data: {
                  "minPrice": minprice,
                  "maxPrice": maxprice,
                  "minArea": minArea,
                  "maxArea": maxArea,
                  "address": address,
                  "roomSum": sumHouse,
              },
              url: "http://localhost:8087/newHouse/selectNew",
              dataType: "json",
              success: function (data) {
                  resolve(data.data)
              },
              error: function (XMLHttpRequest, textStatus, errorThrown) {
                  reject("失败");
              }
          });
      });
}
